package com.data.common.util;
import com.alibaba.ttl.TransmittableThreadLocal;
import com.data.common.aspect.annotation.DataAuditLogging;
import com.data.common.entity.OperationDataChange;
import org.aspectj.lang.JoinPoint;

import java.util.List;

/**
 * CG
 */
public class DataOperateLogThreadLocal {

    public static final String TRACE_ID = "threaddata_id";

    public static final String USER_TOKEN = "user_token";

    /**
     * 注解
     */
    public static final TransmittableThreadLocal<DataAuditLogging> DATA_LOG = new TransmittableThreadLocal<>();
    /**
     * 切点
     */
    public static final TransmittableThreadLocal<JoinPoint> JOIN_POINT = new TransmittableThreadLocal<>();
    /**
     * 数据变化
     */
    public static final TransmittableThreadLocal<List<OperationDataChange>> DATA_CHANGES = new TransmittableThreadLocal<>();

    /**
     * 当前线程操作生成的唯一ID
     */
    @SuppressWarnings("rawtypes")
    public static final TransmittableThreadLocal THREADDATA_ID = new TransmittableThreadLocal();

    /**
     * 当前操作的调用的方法
     */
    public static final TransmittableThreadLocal THREADDATA_METHOD = new TransmittableThreadLocal();


    /**
     * <p>
     * 调用
     * </p>
     */
    public static void transfer() {
        DATA_CHANGES.remove();
        DATA_LOG.remove();
        JOIN_POINT.remove();
        THREADDATA_ID.remove();
        THREADDATA_METHOD.remove();
    }

}